package cx3k.scheduler.objects;

import java.util.ArrayList;
import cx3k.GUI.ScheduledCourseGroup;

public class Schedule {
	int scheduleProfile;
	int scheduleId;
	String scheduleName;
	// add grouping instead which contains classes, if grouping of classes is 1, set boolean to disable dropdown menu
	//List <Semester> semesters;
	ArrayList <AcademicYear> academicYears = new ArrayList<AcademicYear>(0);
	
	public Schedule(){
		this(0, 0, "N/A");
	}
	
	public Schedule(int scheduleProfile, int scheduleId, String scheduleName){
		this.scheduleProfile = scheduleProfile;
		this.scheduleId = scheduleId;
		this.scheduleName = new String(scheduleName);
	}
	
	public Schedule(Schedule temp){
		this(temp.scheduleProfile, temp.scheduleId, temp.scheduleName);
	}
	
	public int getScheduleProfile(){
		return this.scheduleProfile;
	}
	public int getScheduleId(){
		return this.scheduleId;
	}
	public String getScheduleName(){
		return new String(this.scheduleName);
	}
	
	/*public void printCourses(){
		for(int i = 0; i < courses.size(); i++)
			System.out.println("SchedName: '" + this.scheduleName + "'  SchedId: " + this.scheduleId + "  ShedProfile: " + this.scheduleProfile
					+ courses.get(i).getCourseId() + "\t" 
					+ courses.get(i).getDescription() 
					+ "\t" + courses.get(i).getSemester().toString());
	}*/
	public ArrayList<AcademicYear> getAcademicYears(){
		return this.academicYears;
	}
	public void addAcademicYear(AcademicYear temp){
		this.academicYears.add(temp);
		//return this.academicYears;
	}

	public void printAll() {
		// TODO Auto-generated method stub
		
	}

	public void setScheduleId(int scheduleCtr) {
		this.scheduleId = scheduleCtr;
	}

	public void setScheduleProfile(int profileId) {
		this.scheduleProfile = profileId;
	}

	public void setScheduleName(String name) {
		this.scheduleName = name;	
	}

	public String getName() {
		return this.scheduleName;
	}

	public AcademicYear[] getYears() {
		
		AcademicYear[] myYears = new AcademicYear[academicYears.size()]; 
		
		int ctr = 0;
		for(AcademicYear myYear: academicYears)
			myYears[ctr++] = myYear;
		
		
		return myYears;
	}
	
	public static void printSchedule(Schedule s) {
		System.out.println("Printing Schedule: " + s.getName() + "\n");
		
		ArrayList<AcademicYear> years = s.getAcademicYears();
		for (AcademicYear year: years) {
			
			System.out.println("Year: " + year.getYearNumber());
			
			ArrayList<ScheduledSemester> semesters = year.getSemesters();
			for (ScheduledSemester semester: semesters) {
				
				System.out.println("\tSemester: " + semester.getTerm());
				
				ArrayList<ScheduledCourseGroup> groups = semester.getGroups();
				for (ScheduledCourseGroup group: groups) {
					
					System.out.println("\t\tGroup of size: " + group.getCoursesList().size());
					
					ArrayList<Course> courses = group.getCoursesList();
					for (Course course: courses) {
						
						System.out.println("\t\t\tCourse: " + course.getName());
						
					}
				}
			}
		}
	}
	
}
